/**
 * 表单项验证 (业务验证)
 */
window.onload = function() {

	var mid = document.getElementById("mid");
	var resetbtn = document.getElementById("btn_reset");
	mid.addEventListener("focusout", function(e) {
		// 1. 验证非空 2.验证邮箱 3. 验证手机号码
		var reg_mail = /^\w+@\w+\.\w+$/;
		var reg_phone = /^(13)\d{9}|(15)(\d{9})|(18)(\d{9})$/;
		if(validateEmpty("mid")){
			validateRegex("mid",reg_mail) || validateRegex("mid",reg_phone);
		} 
	}, false);

	resetbtn.addEventListener("click", function(e) {
		mid.className = "init";
		document.getElementById("mid_msg").innerHTML = "";
	}, false);

}

// 方法放到外面要不闭包看不见
function validateAll() {
	var reg_mail = /^\w+@\w+\.\w+$/;
	var reg_phone = /^(13)\d{9}|(15)\d{9}|(18)\d{9}$/;
	if(!validateEmpty("mid")){
		return false;
	}
	return  validateRegex(reg_mail) || validateRegex(reg_phone);
}